package com.aisile.rabbitmq.listener;

import com.aisile.rabbitmq.config.RabbitMQConfigCJ;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;
import java.util.Date;

/**
 * @Auther:yry
 * @Date:2024/1/12 0012
 * @VERSON:1.0
 */
@Component
@RabbitListener(queues = RabbitMQConfigCJ.cj_QUEUE)
public class CumMQListenerCJ {

    @RabbitHandler
    public void msg(@Payload Object msg) throws UnsupportedEncodingException {
        System.out.println(new Date());
        Message message = (Message)msg;
        String str = new String(message.getBody(),"utf-8");
        System.out.println(str);
    }
}
